﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;

namespace Hypermarket_Serial_Port
{
    class ReceiveDataManager
    {
        //private static ReceiveDataManager mInstance;
        //private static SerialPort mySerialPort = new SerialPort("COM13");
        //private ReceiveDataManager()
        //{
        //    try
        //    {
        //        mySerialPort.BaudRate = 9600;
        //        mySerialPort.Parity = Parity.None;
        //        mySerialPort.StopBits = StopBits.Two;
        //        mySerialPort.DataBits = 8;
        //        mySerialPort.Handshake = Handshake.None;
        //        mySerialPort.ReadTimeout = 10;
        //        mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
        //    }
        //    catch
        //    {
        //        throw;
        //    }
        //}

        //public static ReceiveDataManager getInstance()
        //{
        //    if (mInstance == null)
        //    {
        //        mInstance = new ReceiveDataManager();
        //    }
        //    return mInstance;
        //}

        //private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        //{
        //    SerialPort sp = (SerialPort)sender;
        //    string indata = sp.ReadExisting();
        //    Console.WriteLine("Data Received:");
        //    Console.Write(indata);
        //    if (mySerialPort.IsOpen)
        //        mySerialPort.Close();
        //}

        //public void OpenSerialPortReceive()
        //{
        //    if(!mySerialPort.IsOpen)
        //        mySerialPort.Open();
        //}

        ////public void CloseSerialPortReceive()
        ////{
            
        ////}
    }
}
